# -*- coding: utf-8 -*-

"""
DateTime   : 2020/12/17 15:49
Author     : ZhangYafei
Description: 被装饰函数含有不定长阐述
"""
import time


def record_time(func):
    def wrapper(*args, **kwargs):
        start_time = time.time()
        func(*args, **kwargs)
        end_time = time.time()
        print('spend is {}'.format(end_time - start_time))

    return wrapper


@record_time       # 得到闭包函数record_time, add = record_time(add)
def add(*args):
    num_sum = sum(num for num in args)
    print(f'{args} sum is {num_sum}')
    time.sleep(1)


add(1,2,3)
add(2,3,4,5)
"""
(1, 2, 3) sum is 6
spend is 1.0004258155822754
(2, 3, 4, 5) sum is 14
spend is 1.0004265308380127
"""